﻿using FatusoAction;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Chimmy.Model;

namespace Chimmy
{
    public class Chimmy
    {
        public static void ExecutarComando(Comando comando, List<string> argumentos)
        {
            List<KeyValuePair<string, string>> subComandos = RecuperaSubComandos(argumentos);
            switch (comando)
            {
                case Comando.Serie:
                    ComandoSerie(subComandos);
                    break;
            }
        }

        private static void ComandoSerie(List<KeyValuePair<string, string>> subComandos)
        {
            int maxTorrent = 5;
            int maxLegenda = 5;
            string release = subComandos.GetByKey("rls");

            ProgramAction.ComandoSerieFilme(release, maxLegenda, maxTorrent, FatusoAction.TipoVideo.Serie, null);
        }

        private static List<KeyValuePair<string, string>> RecuperaSubComandos(List<string> argumentos)
        {
            List<KeyValuePair<string, string>> retorno = new List<KeyValuePair<string,string>>();
            foreach (string argumento in argumentos)
            {
                string key = argumento.Split(' ')[0];
                string value = argumento.Remove(0, key.Length).Trim();
                retorno.Add(new KeyValuePair<string, string>(key, value));
            }
            return retorno;
        }

    }
}
